package com.pay.controller;

import com.pay.dto.MemberDto;
import com.pay.dto.ResponseEntity;
import com.pay.entity.TbBusinessOrder;
import com.pay.service.TbBusinessOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/order")
@Api(tags = "订单控制层")
public class OrderController {
    @Resource
    TbBusinessOrderService tbBusinessOrderService;

    @GetMapping("/getLiveType")
    @ApiOperation("选择会员时间")
    public ResponseEntity getLiveType(){
       return tbBusinessOrderService.getLiveType();
    }

    @GetMapping("/selByTypeId")
    @ApiOperation("根据会员id查询所对应的数据")
    public ResponseEntity selByTypeId(@RequestParam(value = "id")Integer id){
        return tbBusinessOrderService.selByTypeId(id);
    }

    @PostMapping("/saveOrder")
    @ApiOperation("生成订单")
    public ResponseEntity saveOrder(@RequestBody MemberDto memberDto, HttpServletRequest request){
        String token = request.getHeader("token");
        return tbBusinessOrderService.saveOrder(memberDto,token);
    }
}
